package firstcontent.buffer;

import java.nio.ByteBuffer;
import java.util.ArrayList;

/**
 * @Author: fxy
 * @Date: 2022/02/21/8:16
 * @Description: //-XX:MetaspaceSize=1G -XX:MaxMetaspaceSize=1G
 * -XX:MaxDirectMemorySize=10m
 */
public class BufferTest2 {
    private static final int BUFFER = 1024*1024;
    public static void main(String[] args) {
        ArrayList<ByteBuffer> list = new ArrayList<>();
        int count = 0;
        try{
            while(true){
                ByteBuffer byteBuffer = ByteBuffer.allocateDirect(BUFFER);
                list.add(byteBuffer);
                count++;
                try{
                    Thread.sleep(1000);
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
        }finally {
            System.out.println(count);
        }
    }
}
